package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 交付计划表
 * @author jw
 */
@Entity
@Table(name = "delivery_plan", schema = "lxh_crm")
public class DeliveryPlan {
    private int deliveryPlanId;
    private Date deliveryPlanDate;
    private Integer isRemind;
    private String remark;
    private Date deliveryMakeDate = new Date();
    private int isOut = 0;

    /** 交付期次 */
    private DeliveryTimes deliveryTime;
    /** 合同 */
    private Contract contract;
    /** 负责人 */
    private Emp principal;
    /** 交付产品 */
    private List<DeliveryProList> deliveryProLists;

    @OneToMany(mappedBy = "deliveryPlan")
    public List<DeliveryProList> getDeliveryProLists() {
        return deliveryProLists;
    }

    public void setDeliveryProLists(List<DeliveryProList> deliveryProLists) {
        this.deliveryProLists = deliveryProLists;
    }

    @ManyToOne
    @JoinColumn(name = "principal")
    public Emp getPrincipal() {
        return principal;
    }

    public void setPrincipal(Emp principal) {
        this.principal = principal;
    }

    @ManyToOne
    @JoinColumn(name = "contract_id")
    public Contract getContract() {
        return contract;
    }

    public void setContract(Contract contract) {
        this.contract = contract;
    }

    @ManyToOne
    @JoinColumn(name = "delivery_times_id")
    public DeliveryTimes getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(DeliveryTimes deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    @Id
    @Column(name = "delivery_plan_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getDeliveryPlanId() {
        return deliveryPlanId;
    }

    public void setDeliveryPlanId(int deliveryPlanId) {
        this.deliveryPlanId = deliveryPlanId;
    }

    @Basic
    @Column(name = "delivery_plan_date", nullable = true)
    public Date getDeliveryPlanDate() {
        return deliveryPlanDate;
    }

    public void setDeliveryPlanDate(Date deliveryPlanDate) {
        this.deliveryPlanDate = deliveryPlanDate;
    }

    @Basic
    @Column(name = "is_remind", nullable = true)
    public Integer getIsRemind() {
        return isRemind;
    }

    public void setIsRemind(Integer isRemind) {
        this.isRemind = isRemind;
    }

    @Basic
    @Column(name = "remark", nullable = true, length = 200)
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Basic
    @Column(name = "delivery_make_date")
    public Date getDeliveryMakeDate() {
        return deliveryMakeDate;
    }

    public void setDeliveryMakeDate(Date deliveryMakeDate) {
        this.deliveryMakeDate = deliveryMakeDate;
    }

    @Basic
    @Column(name = "is_out",nullable = false)
    public int getIsOut() {
        return isOut;
    }

    public void setIsOut(int isOut) {
        this.isOut = isOut;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DeliveryPlan that = (DeliveryPlan) o;
        return deliveryPlanId == that.deliveryPlanId &&
                isOut == that.isOut &&
                Objects.equals(deliveryPlanDate, that.deliveryPlanDate) &&
                Objects.equals(isRemind, that.isRemind) &&
                Objects.equals(remark, that.remark) &&
                Objects.equals(deliveryMakeDate, that.deliveryMakeDate) &&
                Objects.equals(deliveryTime, that.deliveryTime) &&
                Objects.equals(contract, that.contract) &&
                Objects.equals(principal, that.principal) &&
                Objects.equals(deliveryProLists, that.deliveryProLists);
    }

    @Override
    public int hashCode() {
        return Objects.hash(deliveryPlanId, deliveryPlanDate, isRemind, remark, deliveryMakeDate, isOut, deliveryTime, contract, principal, deliveryProLists);
    }

    @Override
    public String toString() {
        return "DeliveryPlan{" +
                "deliveryPlanId=" + deliveryPlanId +
                ", deliveryPlanDate=" + deliveryPlanDate +
                ", isRemind=" + isRemind +
                ", remark='" + remark + '\'' +
                ", deliveryMakeDate=" + deliveryMakeDate +
                ", isOut=" + isOut +
                ", deliveryTime=" + deliveryTime +
                ", contract=" + contract +
                ", principal=" + principal +
                ", deliveryProLists=" + deliveryProLists +
                '}';
    }
}
